import { PreferenPanel } from "../shopMall/PreferenPanel";
import { SMoney } from "../../../../Message/Game/SMoney";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { ResouceConst } from "../../../component/gconst/ResouceConst";
import { ImagesConst } from "../../resource/ImagesConst";
import { LoaderHelp } from "../../../common/display/LoaderHelp";
import { ResFileConst } from "../../resource/ResFileConst";
import { ObjCreate } from "../common/ObjCreate";
import { Language } from "../../../../extend/language/Language";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { SecTimerView } from "../common/SecTimerView";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { TilePanel } from "../equipment/TilePanel";
import { WelPreferenRender } from "./WelPreferenRender";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { GButton } from "../../../../com/mui/controls/GButton";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
type int = number;
//class WelfarePreferenPanel
    
    export  class WelfarePreferenPanel extends PreferenPanel
    {
        constructor()
        {
            super();
            return;
        }

        public setSize(arg1: int, arg2: int): void
        {
            this._width = arg1 + 2;
            this._height = arg2 + 2;
            _preperenBg.setSize(this.width, this.height);
            _itemListPanel.setSize(this.width - 5, 270);
            _itemListPanel.columnWidth = this.width;
            return;
        }

        public updateRoleMoney(arg1: SMoney): void
        {
            this._moneyTxt.text = arg1.gold + "";
            return;
        }

        /* internal  */onMoneyBtnClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.GotoPay));
            return;
        }

        protected /* override */ createChildren(): void
        {
            _preperenBg = ResouceConst.getScaleBitmap(ImagesConst.PreperenBg);
            _preperenBg.x = 0;
            _preperenBg.y = 0;
            addChild(_preperenBg);
            _preperenTitle = new Object /* flash.display.Bitmap */();
            _preperenTitle.x = 25;
            _preperenTitle.y = 5;
            this.addChild(_preperenTitle);
            LoaderHelp.addResCallBack(ResFileConst.shopMall, this.updateBitmap);
            ObjCreate.createBg(5, 35, 205, 1, this, ImagesConst.SeptalLine);
            ObjCreate.createBg(0, 40, 220, 22, this, ImagesConst.RemainningTimeBg);
            ObjCreate.createTextField(Language.getString(90226), 35, 41, 140, 20, this, new GTextFormat(FontUtil.songtiName, 14, 65280));
            _timeTxtView = new SecTimerView();
            _timeTxtView.mouseEnabled = false;
            var loc1=new GTextFormat(FontUtil.songtiName, 14, 15788607);
            loc1.align = flash.text.TextFormatAlign.LEFT;
            _timeTxtView.defaultTextFormat = loc1;
            _timeTxtView.filters = [FilterConst.glowFilter];
            _timeTxtView.setParse(Language.getString(53084));
            ObjCreate.setObjAttri(_timeTxtView, 105, 41, 150, 25, this);
            _itemListPanel = new TilePanel();
            _itemListPanel.setSize(215, 270);
            _itemListPanel.columnWidth = 215;
            _itemListPanel.rowHeight = 90;
            _itemListPanel.setStyle("cellRenderer", WelPreferenRender);
            _itemListPanel.move(5, 65);
            addChild(_itemListPanel);
            _backInput = ObjCreate.createGTextInput(60, 273, 110, 20, this);
            _backInput.editable = false;
            _backInput.visible = false;
            _getBackBtn = ObjCreate.createGButton(Language.getString(20564), 175, 273, 50, 20, this, "Button");
            _getBackBtn.addEventListener(flash.events.MouseEvent.CLICK, onGetBackBtnClickHandler);
            _getBackBtn.visible = false;
            _tipTxt = ObjCreate.createTextField("", 35, 340, 200, 40, this);
            _tipTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            _tipTxt.multiline = true;
            _tipTxt.wordWrap = true;
            this._moneyIcon = GlobalClass.getBitmap(ImagesConst.Yuanbao_small);
            this._moneyIcon.x = 25;
            this._moneyIcon.y = 370;
            addChild(this._moneyIcon);
            this._moneyTxt = new Object /* flash.text.TextField */();
            this._moneyTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._moneyTxt.mouseEnabled = false;
            this._moneyTxt.width = 200;
            this._moneyTxt.height = 18;
            this._moneyTxt.x = this._moneyIcon.x + this._moneyIcon.width + 2;
            this._moneyTxt.y = this._moneyIcon.y - 2;
            this._moneyTxt.textColor = 16776960;
            addChild(this._moneyTxt);
            this._moneyBtn = new GButton();
            this._moneyBtn.setSize(78, 26);
            this._moneyBtn.styleName = "ButtonRed";
            this._moneyBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onMoneyBtnClickHandler);
            this._moneyBtn.textField.filters = [FilterConst.glowFilter];
            this._moneyBtn.label = Language.getString(20624);
            this._moneyBtn.x = 110;
            this._moneyBtn.y = this._moneyIcon.y - 6;
            addChild(this._moneyBtn);
            return;
        }

        protected /* override */ updateTips(): void
        {
            _tipTxt.htmlText = HTMLUtil.addColor(Language.getString(25011), "#ffff00");
            return;
        }

        public /* override */ get width(): number
        {
            return this._width;
        }

        public /* override */ get height(): number
        {
            return this._height;
        }

        /* internal  */updateBitmap(): void
        {
            _preperenTitle.bitmapData = GlobalClass.getBitmapData(ImagesConst.PreperenTitle);
            return;
        }

        /* internal */ /* var */_width: int;

        /* internal */ /* var */_height: int;

        /* internal */ /* var */_moneyIcon: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_moneyTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_moneyBtn: GButton;
    }
